<template>
  <el-col :span="7">
    <el-input style="padding-left: 20px;" size="large"
              v-model="query" type="text"
              :placeholder=props.placeholderContext clearable
    />
  </el-col>
  <el-button  size="large" type="primary" :icon="Search" @click="searchEvent">{{ props.searchText }}</el-button>
  <el-button  size="large" type="primary" @click="addEvent">{{ props.addText }}</el-button>
</template>

<script setup>
import {Search} from '@element-plus/icons-vue'
import {ref} from 'vue'


const query = ref('')
const props = defineProps({
  placeholderContext: String,
  searchText: String,
  addText: String
})
const emits = defineEmits([
  "initGetLandInfo",
  "handleDialogLandValue",

  "initGetProductInfo",
  "handleDialogProductValue",

  "initCgInfo",
  "handleDialogCgValue",

  "initUseInfo",
  "handleDialogUseValue",

  "initNsInfo",
  "handleDialogNsValue",

  "initIotInfo",
  "handleDialogIotValue",

  "initCpInfo",
  "handleDialogCpValue",

  "initJcInfo",
  "handleDialogJcValue",

  "initJgInfo",
  "handleDialogJgValue",

  "initStInfo",
  "handleDialogStValue",

  "initIsInfo",
  "handleDialogIsValue",

  "initOsInfo",
  "handleDialogOsValue",

  "initKhInfo",
  "handleDialogKhValue",

  "initJyInfo",
  "handleDialogJyValue",

  "initWlInfo",
  "handleDialogWlValue",

  "initProEviInfo",
  "handleDialogProEviValue"
])
const searchEvent = () => {
  // console.log(props.searchText)
  if (props.searchText === "搜索地块") {
    emits('initGetLandInfo', query)
  } else if (props.searchText === "搜索产品") {
    emits("initGetProductInfo", query)
  } else if (props.searchText === "搜索投入品") {
    emits('initCgInfo', query)
  } else if (props.searchText === "搜索使用信息") {
    emits('initUseInfo', query)
  } else if (props.searchText === "搜索农事信息") {
    emits('initNsInfo', query)
  }  else if (props.searchText === "搜索生产环境数据") {
    emits('initIotInfo', query)
  } else if (props.searchText === "搜索产品生产信息") {
    emits('initCpInfo', query)
  } else if (props.searchText === "搜索检测信息") {
    emits('initJcInfo', query)
  } else if (props.searchText === "搜索加工信息") {
    emits('initJgInfo', query)
  } else if (props.searchText === "搜索仓库信息") {
    emits('initStInfo', query)
  } else if (props.searchText === "搜索入库信息") {
    emits('initIsInfo', query)
  } else if (props.searchText === "搜索出库信息") {
    emits('initOsInfo', query)
  } else if (props.searchText === "搜索客户信息") {
    emits('initKhInfo', query)
  } else if (props.searchText === "搜索交易数据") {
    emits('initJyInfo', query)
  } else if (props.searchText === "搜索物流信息") {
    emits('initWlInfo', query)
  } else if (props.searchText === "搜索上链信息") {
    emits('initProEviInfo', query)
  }
}
const addEvent = () => {
  if (props.addText === "新增地块") {
    emits("handleDialogLandValue", null)
  } else if (props.addText === "添加产品"){
    emits("handleDialogProductValue", null)
  } else if (props.addText === "新增投入品"){
    emits("handleDialogCgValue", null)
  } else if (props.addText === "新增使用信息") {
    emits("handleDialogUseValue", null)
  } else if (props.addText === "新增生产环境数据") {
    emits("handleDialogIotValue", null)
  } else if (props.addText === "新增农事作业") {
    emits("handleDialogNsValue", null)
  } else if (props.addText === "新增产品生产信息") {
    emits("handleDialogCpValue", null)
  } else if (props.addText === "新增检测信息") {
    emits("handleDialogJcValue", null)
  } else if (props.addText === "添加加工信息") {
    emits("handleDialogJgValue", null)
  } else if (props.addText === "新增仓库信息") {
    emits("handleDialogStValue", null)
  } else if (props.addText === "新增入库信息") {
    emits("handleDialogIsValue", null)
  } else if (props.addText === "新增出库信息") {
    emits("handleDialogOsValue", null)
  } else if (props.addText === "新增客户信息") {
    emits("handleDialogKhValue", null)
  } else if (props.addText === "新增交易数据") {
    emits("handleDialogJyValue", null)
  } else if (props.addText === "新增物流信息") {
    emits("handleDialogWlValue", null)
  } else if (props.addText === "添加上链信息") {
    emits("handleDialogProEviValue", null)
  }
}
</script>

<style scoped>

</style>




<!--      <el-col :span="7">
        <el-input style="padding-left: 20px;" size="large" v-model="queryForm.query" type="text" placeholder="请输入地块名称" clearable/>
      </el-col>
      <el-button  size="large" type="primary" :icon="Search" @click="initGetLandInfo">搜索地块</el-button>
      <el-button  size="large" type="primary" @click="handleDialogLandValue(null)">新增地块</el-button>-->

<!--      <el-col :span="7">
        <el-input style="padding-left: 20px;" size="large" v-model="queryForm.query" type="text" placeholder="请输入产品名称" clearable/>
      </el-col>
      <el-button size="large" type="primary" :icon="Search" @click="initGetProductInfo">搜索产品</el-button>
      <el-button size="large" type="primary" @click="handleDialogProductValue(null)">添加产品</el-button>-->